package service

import (
	"apitestAfterGo/dao"
	"apitestAfterGo/domain"
)

type userDetailsService struct {
	userDetailsMapper  *domain.UserDetailsMapper
	InsertByUserDetail func(id int) error                     `tx:"" rollback:"error"`
	UpdateByUserInfo   func(details domain.UserDetails) error `tx:"" rollback:"error"`
}

var UserDetailsServiceImpl userDetailsService

func init() {
	UserDetailsServiceImpl = userDetailsService{
		userDetailsMapper: &dao.UserDetailsMapper,
		InsertByUserDetail: func(id int) error {
			return UserDetailsServiceImpl.userDetailsMapper.InsertByUserDetail(id)
		},
		UpdateByUserInfo: func(details domain.UserDetails) error {
			return UserDetailsServiceImpl.userDetailsMapper.UpdateByUserInfo(details)
		},
	}
}
